package com.blockchain.console.servlets.financial.ptzjgl;

import java.sql.Timestamp;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.blockchain.common.enums.PlatformFundType;
import com.blockchain.common.enums.PtXlbType;
import com.blockchain.console.service.financial.PtzjManage;
import com.blockchain.console.service.financial.entity.PtzjglRecord;
import com.blockchain.console.service.financial.query.PtzjglRecordQuery;
import com.blockchain.console.service.trading.TradingManage;
import com.blockchain.console.service.trading.entity.XlbEntity;
import com.blockchain.console.servlets.financial.AbstractFinancialServlet;
import com.blockchain.framework.http.servlet.annotation.Right;
import com.blockchain.framework.resource.PromptLevel;
import com.blockchain.framework.service.ServiceSession;
import com.blockchain.framework.service.query.Paging;
import com.blockchain.framework.service.query.PagingResult;
import com.blockchain.util.parser.EnumParser;
import com.blockchain.util.parser.IntegerParser;
import com.blockchain.util.parser.TimestampParser;

@Right(id = "C_FINANCE_PTXLBJYJLLIST", name = "平台虚拟币账户管理-交易记录")
public class PtxlbjyjlList extends AbstractFinancialServlet {
	private static final long serialVersionUID = 1L;

	@Override
	protected void processGet(HttpServletRequest request, HttpServletResponse response, ServiceSession serviceSession)
			throws Throwable {
		processPost(request, response, serviceSession);
	}

	@Override
	protected void processPost(final HttpServletRequest request, final HttpServletResponse response,
			final ServiceSession serviceSession) throws Throwable {
		PtzjManage ptzjManage = serviceSession.getService(PtzjManage.class);
		int bid = IntegerParser.parse(request.getParameter("bid"));
		TradingManage tsradingManage = serviceSession.getService(TradingManage.class);
		XlbEntity[] xlb = tsradingManage.getXlbxx();
		PagingResult<PtzjglRecord> result = ptzjManage.searchJyjl(bid, new PtzjglRecordQuery() {
			@Override
			public PlatformFundType getType() {
				return null;
			}

			@Override
			public Timestamp getStartPayTime() {
				return TimestampParser.parse(request.getParameter("startPayTime"));
			}

			@Override
			public Timestamp getEndPayTime() {
				return TimestampParser.parse(request.getParameter("endPayTime"));
			}

			@Override
			public String getUserName() {
				return request.getParameter("userName");
			}

			@Override
			public String getXm() {
				return request.getParameter("xm");
			}

			@Override
			public PtXlbType getPtXlbType() {
			 return EnumParser.parse(PtXlbType.class, request.getParameter("type"));
			}
		}, new Paging() {

			@Override
			public int getSize() {
				return 10;
			}

			@Override
			public int getCurrentPage() {
				return IntegerParser.parse(request.getParameter(PAGING_CURRENT));
			}
		});
		getController().prompt(request, response, PromptLevel.WARRING, request.getParameter("message"));
		request.setAttribute("result", result);
		request.setAttribute("xlb", xlb);
		request.setAttribute("bid", bid);
		forwardView(request, response, getClass());
	}
}
